<?php
	$s=0;
	$n=2;
	$pg=$_REQUEST['pn'];
	
	if(empty($_REQUEST["nr"]) ) 
    { 
		$n = 5;
		
    }
	else
	{
		$n = $_REQUEST['nr']; ;
	} 

 if(empty($_REQUEST["pn"]) && $_REQUEST["pn"]=='') 
    { 
		$s =0;
		$pg=1;
        
    } 
    else 
    { 
		$s = ($_REQUEST["pn"]*$n)-$n;
        
    }


    function paginate($num_rows,$num_records,$start)
    {
           $br1=5;
           $br2=1;
           if($num_rows%$num_records)
            {
               $k=($num_rows/$num_records)+1;
            }
           else
            {
               $k=$num_rows/$num_records;
            }
            $f=ceil($br1/$br2);
            $ed=$f;
            if($k!='')
             {
               if($num_records<$num_rows)
                {
                  echo '<ul id="nav"><li>Page No.s : &nbsp;&nbsp;</li>';
                  if($start>1)			
                   {
                     $newstart=$start-1;
                     echo "<li><span onclick='arrange($num_records,1);'>
					 <img src='images/nav1.gif' width=11 height=12 />&nbsp;&nbsp;</span></li>";
                     echo "<li><span onclick='arrange($num_records,$newstart);'>
					 <img src='images/nav3.gif' width=11 height=12 />&nbsp;</span></li>";
                   }
                   for($j=1; $j<=$ed && $j<=$k; $j++)
                   {
                    if($start<=$ed)
                     {
                       if($start!=$j)
                        {
                           echo "<li><a href='#' onclick='arrange($num_records,$j);'>&nbsp;$j&nbsp;</a></li>"; 
                        }
                       else
                        {
                          echo '<span class="nav_active">';
                          echo "&nbsp;".$j."&nbsp;";
                          echo '</span>';
                        }
                     }
                     else
                     {
                       $j=$ed;
                       $ed+=$f;
                     }
                   }
                   if($start<floor($k))			
                    {
                       $newstart=$start+1;
                       echo "<li><span onclick='arrange($num_records,$newstart);'>
					   <img src='images/nav4.gif' width=11 height=12 />&nbsp;</span></li>";
                       echo "<li><span onclick='arrange($num_records,".floor($k).");'>&nbsp;
					   <img src='images/nav2.gif' width=11 height=12 />&nbsp;&nbsp;</span></li></ul>";
                    }
				 }
			  }
	}			  
?>									  